<?php
/**
 * @author Aurelijus Banelis
 */
class Upgrade {
    public static function checkForecastHystory() {
        $sqlResult = DB::query("SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'foresee_hystory' AND table_schema = DATABASE()");
        if ($sqlResult) {
            list($exists) = DB::row($sqlResult);
        } else {
            $exists = false;
        }
        if (!$exists) {
            DB::query('
                CREATE TABLE IF NOT EXISTS `foresee_hystory` (
                  `id` bigint(20) NOT NULL AUTO_INCREMENT,
                  `name` varchar(256) DEFAULT NULL,
                  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                  `value` text NOT NULL,
                  PRIMARY KEY (`id`)
                ) CHARSET=utf8 COLLATE=utf8_bin COMMENT=\'Saved configurations for load foresee\' AUTO_INCREMENT=1 ;
            ');
        }
    }
}